﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace MyBlog2.Models
{
    public class Comment
    {
        public Comment()
        {
            this.Avatar = "/images/touxiang.jpg";
            this.ReplyComments = new HashSet<Comment>();
        }

        [Key]
        public int Id { get; set; }

        [Display(Name = "文章id")]
        public int ArticleId { get; set; }

        [Display(Name = "昵称")]
        [Required(ErrorMessage = "{0}不能为空")]
        public string Nickname { get; set; }

        [Display(Name = "邮箱")]
        [Required(ErrorMessage = "{0}不能为空")]
        [DataType(DataType.EmailAddress)]
        public string Email { get; set; }

        [Display(Name = "头像")]
        public string Avatar { get; set; }


        [Display(Name = "评论内容")]
        public string Contents { get; set; }

        [Display(Name = "添加时间")]
        public DateTime AddTime { get; set; }

        public bool AdminComment { get; set; }  //是否管理员评论

        public virtual Article Article { get; set; }    //关联文章

        public virtual ICollection<Comment> ReplyComments { get; set; }    //子评论集合

        public virtual Comment ParentComment { get; set; }  //父评论
    }
}
